<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>键盘事件</title>
</head>
<body>
<script type="text/javascript">
document.body.onkeydown = function (argument) {
	console.log(argument);
	switch(argument.keyCode){
		case 87:
			alert('向上走');
			break;
		case 65:
			alert('向左走');
			break;
		case 83:
			alert('向下走');
			break;
		case 68:
			alert('向右走');
			break;
	}
}

</script>
</body>
</html>